const state = {
    historyList:JSON.parse(localStorage.getItem('historyList'))||[]
}
const mutations = {
    SET_HISORY_LIST(state,history){
        state.historyList=history
    },
    CLEAR_HISORY_LIST(state){
        state.historyList=[]
    }
}
const actions = {
    getHistory({commit,state},history){
        let list=state.historyList
        list.unshift(history)
        localStorage.setItem('historyList',JSON.stringify(list))
        commit('SET_HISORY_LIST',list)
    },
    clearHistory({commit,state}){
        localStorage.removeItem('historyList');
        commit('CLEAR_HISORY_LIST')
    }
}
export default {
  state,
  mutations,
  actions
}